#
#= プロジェクトアイテムクラス
#
#
#
class ClsProjectitem
  attr_reader :isclass
  attr_reader :projectcomp
  attr_reader :class_level


  #
  #=== コンストラクタ
  #
  #
  def initialize( isclass, level, projectcomp )
    @isclass = isclass
    @projectcomp = projectcomp
    @class_level = level
  end


  #
  #=== 分類名を返す
  #
  #
  def name
    name = ""
    if self.isclass
      if self.level == 0
        name = self.projectcomp.class_word1.to_s
      elsif self.level == 1
        name = self.projectcomp.class_word2.to_s
      elsif self.level == 2
        name = self.projectcomp.class_word3.to_s
      end
    else
      name = self.projectcomp.item_name
    end
    return name
  end


  #
  #=== レベルを返す
  #
  #
  def level
    level = 0
    if self.isclass
      level = self.class_level
    else
      if self.projectcomp.class_word3.to_s != ""
        level = 3
      elsif self.projectcomp.class_word2.to_s != ""
        level = 2
      elsif self.projectcomp.class_word1.to_s != ""
        level = 1
      end
    end
    return level
  end


  #
  #=== プロジェクト構成オブジェクトをJSON形式で返す
  #
  #
  def to_json
    return self.projectcomp.to_json
  end
end